package com.cskaoyan.day7;

public class StudentTest {
    public static void main(String[] args) {
        StudentA s1 = new StudentA("张三", 100, "男", 12, 90);
        StudentA s2 = new StudentA("李四", 100, "男", 13, 91);
        StudentA s3 = new StudentA("王五", 100, "男", 13, 92);
        StudentA s4 = new StudentA("QQ", 100, "女", 13, 99);
        StudentA s5 = new StudentA("WW", 100, "女", 13, 100);
        StudentA[] students = {s1, s2, s3, s4, s5};
        print(students);
        System.out.println(avgScore(students));
    }

    private static double avgScore(StudentA[] students) {
        double sum = 0;
        for (StudentA student : students) {
            sum += student.score;
        }
        return sum / students.length;
    }

    private static void print(StudentA[] students) {
        for (StudentA student : students) {
            System.out.println(student.print());
        }
    }
}

class StudentA {
    String name;
    int stuId;
    String gender;
    int age;
    double score;

    public StudentA(String name, int stuId, String gender, int age, double score) {
        this.name = name;
        this.stuId = stuId;
        this.gender = gender;
        this.age = age;
        this.score = score;
    }


    public String print() {
        return "StudentA{" +
                "name='" + name + '\'' +
                ", stuId=" + stuId +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}
